package DemoBall;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;

import javax.swing.JPanel;

public class BallPanel extends JPanel{
	public ArrayList<Ball> balls = new ArrayList<Ball>(); 
	public void add(Ball b){
		balls.add(b);
	}	
	public void paintComponent(Graphics g){
		super.paintComponent(g); 
		Graphics2D g2 = (Graphics2D) g;	
		
		for(Ball b : balls){
			int x = balls.indexOf(b);
			x = x%255;
			int y = balls.indexOf(b)*10;
			y = y%255;
			int z = balls.indexOf(b)*100;
			z = z%255;
			
			Color c = new Color(x,y,z);
			g2.setColor(c);
			g2.fill(b.getShape());
		}
	}
}
